<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>登入 - layuiAdmin</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../static/admin/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../static/admin/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="../static/admin/layuiadmin/style/login.css" media="all">
</head>
<body>

<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>layuiAdmin</h2>
            <p>layui 官方出品的单页面后台管理模板系统</p>
        </div>
        @yield('content')
    </div>
</div>

<script src="../static/admin/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '../static/admin/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'user'], function () {
        var $ = layui.$
            , admin = layui.admin
            , form = layui.form;

        form.render();

        //提交
        form.on('submit(admin-login-submit)', function (obj) {
            $.ajax({
                url: '/backer/doLogin',
                type: 'post',
                data: obj.field,
                success: function (result) {
                    if (result.code == 0) {
                        //清除所有的localStorage
                        //localStorage.clear();
                        layer.msg(result.msg, {time: 1000, icon: 6}, function () {
                            location.href = '/backer'; //后台主页
                        });
                    } else {
                        layer.msg(result.msg, {time: 2000, icon: 5});
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
</html>